package org.cloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;


@Configuration
public class RestTemplateConfig {
    @Bean
    // 启动负载均衡
    // 注意: 启动负载均衡的话 spring.application.name 不能带有下划线, 服务名不要使用下划线，否则报错 Request URI does not contain a valid hostname
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }
}
